﻿PageSetting = {

    init: function () {
        var menuId = -1000;
        if ($.cookie("menuid") != null) {
            menuId = parseInt($.cookie("menuid"));
        }
        $("#Menu").accordion({
            collapsible: true,
            active: menuId,
            heightStyle: "content"
        });
        $("#Menu > h3").click(function () {
            var index = $("#Menu").accordion("option", "active");
            $.cookie("menuid", index, { expires: 1, path: "/" });
        });
        $("#button-search").live("click", function (e) {
            var kw = $("#txt-search").val().trim();
            if (kw.length == 0) {
                alert("Bạn chưa nhận từ khóa.");
                $("#txt-search").focus();
                return;
            }
            window.location = $("#hdnRootUrl").val() + "Search=" + kw;
        });
        $("#button-search").live("keydown", function (e) {
            if (e.keyCode != 13) return;
            var kw = $("#txt-search").val().trim();
            if (kw.length == 0) {
                alert("Bạn chưa nhận từ khóa.");
                $("#txt-search").focus();
                return;
            }
            window.location = $("#hdnRootUrl").val() + "Search=" + kw;
        });        
        $("#search-button").click(function () {
            var keyword = $("#search-box").val();
            if (keyword.length == 0) {
                alert("Bạn chưa nhập từ khóa tìm kiếm.");
                return;
            }
            keyword = $("#hdnRootUrl").val() + "Search/keyword=" + keyword
            window.location = keyword;
        });
        $("#search-box").live("keydown", function (e) {
            if (e.keyCode != 13) return;
            var keyword = $(this).val();
            if (keyword.length == 0) {
                alert("Bạn chưa nhận từ khóa.")
                return;
            }
            keyword = $("#hdnRootUrl").val() + "Search/keyword=" + keyword
            window.location = keyword;
        });
    }
}

$(document).ready(function() {
    PageSetting.init();
})
function QuangCaoClick() {
    window.location = $("#hdnRootUrl").val() + "dich-vu-thiet-ke-he-thong-mang";
}
function disableEnterKey(e) {
    var key;
    if (window.event)
        key = window.event.keyCode; //IE
    else
        key = e.which; //firefox      

    return (key != 13);
}